x86/vvmx: make updating shadow EPTP value more efficient
authorSergey Dyasli <sergey.dyasli@citrix.com>
Tue, 3 Oct 2017 15:21:00 +0000 (16:21 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 6 Oct 2017 12:36:43 +0000 (13:36 +0100)
commit7b6546e8314799053ce17241a493742912ad8809
tree6181f97424c41dbec2012a67a1d710ba462ad892
parentec832dddc4c5a8794d6d89448da2b14186da1baf
x86/vvmx: make updating shadow EPTP value more efficient

At the moment, the shadow EPTP value is written unconditionally in
ept_handle_violation().

Instead, write the value on vmentry to the guest; but only write it if
the value needs updating.

To detect this, add a flag to the nestedvcpu struct, stale_np2m, to
indicate when such an action is necessary.  Set it when the nested p2m
changes or when the np2m is flushed by an IPI, and clear it when we
write the new value.

Since an IPI invalidating the p2m may happen between
nvmx_switch_guest() and vmx_vmenter, but we can't perform the vmwrite
with interrupts disabled, check the flag just before entering the
guest and restart the vmentry if it's set.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
xen/arch/x86/hvm/nestedhvm.c
xen/arch/x86/hvm/vmx/entry.S
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/hvm/vmx/vvmx.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/hvm/vcpu.h